package com.zxkj.commonpatrol.viewmodel;

import android.app.Application;

import androidx.annotation.NonNull;

import com.allen.library.RxHttpUtils;
import com.czy.basecommon.utils.base.BaseRepository;
import com.czy.basecommon.utils.base.BaseViewModel;
import com.czy.basecommon.utils.base.StateLiveData;
import com.zxkj.commonpatrol.model.entity.SelectProjectEntrity;
import com.zxkj.commonpatrol.model.response.SearchProjectResponse;
import com.zxkj.commonpatrol.repoisity.AddCheckPointRepoisity;
import com.zxkj.commonpatrol.repoisity.SelectProjectsRepoisity;

import java.util.List;

public class SelectProjectsViewModel extends BaseViewModel<SelectProjectsRepoisity> {
    public StateLiveData< List<SearchProjectResponse.RowsBean>> data=new StateLiveData<>();
    public SelectProjectsViewModel(@NonNull Application application) {
        super(application);
    }



    public void  getSelectData(String CustomerCode,String Filter,int PageIndex,int PageSize){
        mRepository.getSelectProject(CustomerCode,Filter,PageIndex,PageSize,new BaseRepository.MyBaseDataCallBack() {
            @Override
            public void onDataSuccessCallBack(Object o) {
                SearchProjectResponse da=(SearchProjectResponse)o;
                List<SearchProjectResponse.RowsBean> rows = da.getRows();
                if (rows!=null){
                    data.postSuccess(rows);
                }

            }

            @Override
            public void onDataFailCallBack(Object o, Object t1) {
                data.postFailure((Integer) o,(String)t1);
            }
        });
    }
    public void text(){
        mRepository.Test();
    }

    @Override
    protected void onCleared() {
        super.onCleared();
        RxHttpUtils.cancel("SelectProject");
    }
}
